<?php

namespace IDock\Insurance\TAIC\Response;

use IDock\Http\Response;
use IDock\Printer\PremiumUnderwritingPrinter;

class UnderwritingResponse extends AllTAICResponse
{
    /*** @var PremiumUnderwritingPrinter $printer */
    public $printer = PremiumUnderwritingPrinter::class;

    public function printerInit(): Response
    {
        $this->printer->inquiryNo = $this->get('proposalNo');
        $this->printer->biInquiryNo = $this->get('busProposalNo');
        $this->printer->ciInquiryNo = $this->get('bzProposalNo');

        $biStatus = $this->get('busUnderWriteFlag', '1');
        $ciStatus = $this->get('bzUnderWriteFlag', '1');

        $this->printer->statusCode = 'U5';

        //核保通过
        if (in_array($biStatus, ['1', '3']) and in_array($ciStatus, ['1', '3'])) {
            $this->printer->statusCode = 'U1';
        }

        //核保失败
        if ($biStatus == '2' or $ciStatus == '2') {
            $this->printer->statusCode = 'U4';
            $this->printer->messageTip = $this->get('dealMassage');
        }

        //人工核保
        if ($biStatus == '9' or $ciStatus == '9') {
            $this->printer->statusCode = 'U3';
            $this->printer->messageTip = $this->get('dealMassage');
        }

        //拒保
        if ($ciStatus == '4' or $biStatus == '4') {
            $this->printer->statusCode = 'U6';
            $this->printer->messageTip = $this->get('dealMassage');
        }

        return $this;
    }
}
